import '../entities/draw_contents.dart';
import 'db_utils.dart';

/// sql 语句工具类
class SqlUtils {
  /// 绘画内容-查询所有
  static Future<List<Map<String, Object?>>?> drawContentQuery() async {
    final list = await DBUtils.db?.query(DrawContent.columnTabName);

    return list;
  }

  /// 绘画内容-根据ID查询
  static Future<List<Map<String, Object?>>?> drawContentQueryId(int id) async {
    final list = await DBUtils.db
        ?.query(DrawContent.columnTabName, where: 'id = ?', whereArgs: [id]);

    return list;
  }

  /// 绘画内容-添加数据
  static Future<int?> drawContentInsert(Map<String, Object?> values) async {
    final id = DBUtils.db?.insert(DrawContent.columnTabName, values);

    return id;
  }

  /// 绘画内容-删除数据
  static Future<int?> drawContentDelete(int id) async {
    final count = await DBUtils.db?.delete(
      DrawContent.columnTabName,
      where: 'id = ?',
      whereArgs: [id],
    );

    return count;
  }
}
